/**
 * Created by wzh on 2016/8/8.
 */
/**
 * Created by wzh on 2016/7/28.
 */
'use strict'
swan_pc
    .factory('OrgContact', function ($resource, DateUtils) {
        return $resource('/api/v2/org_contacts/:cid', {cid:'@cid'}, {
            'query': { method: 'GET', isArray: true},
            'queryAll': {
                method: 'GET',
                transformResponse: function (data) {
                    data = angular.fromJson(data);
                    //data.baseInfo.birthDate = DateUtils.convertLocaleDateFromServer(data.baseInfo.birthDate);
                    return data;
                }
            },
            'get': {
                method: 'GET',
                transformResponse: function (data) {
                    data = angular.fromJson(data);
                    //data.birthDate = DateUtils.convertLocaleDateFromServer(data.birthDate);
                    return data;
                }
            },
            'update': {
                method: 'PUT',
                transformRequest: function (data) {
                    //data.baseInfo.birthDate = DateUtils.convertLocaleDateToServer(data.baseInfo.birthDate);
                    return angular.toJson(data);
                }
            },
            'save': {
                method: 'POST',
                transformRequest: function (data) {
                    data.baseInfo.birthDate = DateUtils.convertLocaleDateToServer(data.baseInfo.birthDate);
                    return angular.toJson(data);
                }
            },
            'delete':{
                method:'DELETE'
            }
        });
    })
    .factory('orgCompany', function ($resource, DateUtils) {
        return $resource('/api/orgCompanys/:infoid', {infoid:'@infoid'}, {
            'query': { method: 'GET', isArray: true},
            'queryAll': {
                method: 'GET',
                transformResponse: function (data) {
                    data = angular.fromJson(data);
                    //data.baseInfo.birthDate = DateUtils.convertLocaleDateFromServer(data.baseInfo.birthDate);
                    return data;
                }
            },
            'update': {
                method: 'PUT',
                transformRequest: function (data) {
                    //data.birthDate = DateUtils.convertLocaleDateToServer(data.birthDate);
                    return angular.toJson(data);
                }
            },
            'save': {
                method: 'POST',
                transformRequest: function (data) {
                    //data.birthDate = DateUtils.convertLocaleDateToServer(data.birthDate);
                    return angular.toJson(data);
                }
            },
            'delete':{
                method:'DELETE'
            }
        });
    });